﻿using DroneExample;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.Sensors;

namespace DroneAPI
{
    class InputProcessing
    {
        private static bool droneFlying = false;

        // returns the next command that should be executed
        public static string NextCommand(uint sequenceNumber)
        {
            InputState state = MainPage.GetState();

            // Determine if the drone needs to take off or land
            if (state.flying && !droneFlying)
            {
                droneFlying = true;
                return DroneMovement.GetDroneTakeoff(sequenceNumber);
            }
            else if (!state.flying && droneFlying)
            {
                droneFlying = false;
                return DroneMovement.GetDroneLand(sequenceNumber);
            }

            if (state.rotateX != 0)
            {
                return DroneMovement.GetDroneRotate(sequenceNumber, state.rotateX);
            }

            return DroneMovement.NullCommand(sequenceNumber);
        }
    }
}

